/*******************************
 Platform : AVR mega16学习板（www.iccavr.com）
 function ：功能函数集
 Clock F  : 3.6864M
 Software : ICCAVR7.14C
 Author   : 林夕依然
 Version  : 09.02.25
 comments :
 ********************************/
#include <avr/io.h>

#include <util/delay.h>


void LED_on(void) //打开所有LED
{
	PORTB = 0X00;
	_delay_ms(100);
}

void LED_off(void) //关闭所有LED
{
	PORTB = 0xFF;
	_delay_ms(100);
}

void LED_01(int i) //LED亮灭控制
{
	PORTB = ~_BV(i); //输出低电平
	_delay_ms(100); //调用延时程序
}

void LED_02(int i) //间隔点亮
{
	PORTB = ~(_BV(i) | _BV(i - 2));
	_delay_ms(100);
}

void LED_03(int i) //相临点亮
{
	PORTB = ~(_BV(i) | _BV(i - 1)); //~后内容需用括号括起来
	_delay_ms(100);
}

void LED_04(int i) //发散聚集点亮
{
	switch (i) {
	case 0:
		PORTB = 0xE7;
		_delay_ms(100);
		break; //延时100ms
	case 1:
		PORTB = 0xDB;
		_delay_ms(100);
		break;
	case 2:
		PORTB = 0xBD;
		_delay_ms(100);
		break;
	case 3:
		PORTB = 0x7E;
		_delay_ms(100);
		break;
	default:
		break;
	}
}

void LED_05(int i) //00,0F,F0,FF方式显示
{
	switch (i) {
	case 0:
		PORTB = 0x00;
		_delay_ms(100);
		break; //延时100ms
	case 1:
		PORTB = 0x0F;
		_delay_ms(100);
		break;
	case 2:
		PORTB = 0xF0;
		_delay_ms(100);
		break;
	case 3:
		PORTB = 0xFF;
		_delay_ms(100);
		break;
	default:
		break;
	}
}

void LED_06(int i) {
	switch (i) {
	case 0:
		PORTB = 0XAA;
		_delay_ms(100);
		break;
	case 1:
		PORTB = 0X55;
		_delay_ms(100);
		break;
	}
}
